<?php
require(dirname(dirname(__FILE__)).'/libs/db.class.php');
class Category{
    public $db;
    function __construct()
    {
        $this->db=new DB();
    }

    function index(){
        $output=['errcode'=>0,'msg'=>'success'];
        echo json_encode($output);
    }

    // 获取分类列表
    function list(){
        $output=['errcode'=>0,'msg'=>'success'];
        $sql="select * from categories";
        $list=$this->db->query($sql);
        if($list){
            $output['data']=$list;
        }else{
            $output['errcode']=1;
            $output['msg']='获取分类失败';
        }
        echo json_encode($output);
    }

}
?>